* 6_MechanismsCampFinance_Overleaf
** Goal: examine campaign finance data
** Beatrice Lee
** Date Created: 2024-06-17
** Last Updated: 2024-07-11 // bal

cd "$Data/Processing"
use state_elections_panel_df5_20240709, clear

************************* dep var mean ***************************************
sum chng_log_inc_rcpts_EYmatch chng_log_top_ninc_rcpts_EYmtch if (year >= 2020 & year <= 2022)
sum chng_log_inc_rcpts_EYmatch chng_log_top_ninc_rcpts_EYmtch if (year > 2012)

********************************* campaign finance vars ****************************************
eststo clear

*1) 2sls ----------------------------------------------------------------

******** USING CHANGES (logged base)- WITH recoded presidential election cycles + dummy control 

* pandemic sample
*** Did Aid Impact Incumbent Receipts?
eststo: ivregress 2sls chng_log_inc_rcpts_EYmatch chng_log_prv_inc_rcpts_EYmtch norm_vote_top2_share_sd EY_switch_dummy (total_1k_muni_aid_per_resident = reps_per_million ) if (year >= 2020 & year <= 2022), vce(cluster state) first
estat firststage

mat fstat = r(singleresults)
estadd scalar fs = fstat[1,4]

*** Did Aid Impact Top Non-Incumbent Receipts?
eststo: ivregress 2sls chng_log_top_ninc_rcpts_EYmtch chng_log_prv_tninc_rcpts_EYmtch norm_vote_top2_share_sd EY_switch_dummy (total_1k_muni_aid_per_resident = reps_per_million ) if (year >= 2020 & year <= 2022), vce(cluster state) first
estat firststage

mat fstat = r(singleresults)
estadd scalar fs = fstat[1,4]

**** Export Table to Latex
cd "$Results"
esttab using "camp_finance_2sls_20240709.tex", replace /// Replace file if it already exists
 collabels("\multicolumn{1}{c}{1l}" "\multicolumn{1}{c}{l2}") ///
 b(3) se(3) nomtitle label star(* 0.10 ** 0.05 *** 0.01) ///
 stats(N r2 fs, fmt(0 3) layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}")  labels(`"Observations"' `"\(R^{2}\)"' `"\(F\)"')) drop(_cons) ///
 booktabs ///
 title("Campaign Finance 2sls") ///
 addnotes("Note: TKTKTKTK")

 ******** USING PAC VS NON-PAC CONTRIBUTIONS (logged base)- WITH recoded presidential election cycles + dummy control 
 
 * pandemic sample
*** Did Aid Impact Incumbent PAC Receipts?
eststo: ivregress 2sls chng_log_inc_pac_EYmatch chng_log_prv_inc_pac_EYmtch norm_vote_top2_share_sd EY_switch_dummy (total_1k_muni_aid_per_resident = reps_per_million ) if (year >= 2020 & year <= 2022), vce(cluster state) first
estat firststage

mat fstat = r(singleresults)
estadd scalar fs = fstat[1,4]

*** Did Aid Impact Top Non-Incumbent PAC Receipts?
eststo: ivregress 2sls chng_log_tninc_pac_EYmtch chng_log_prv_tninc_pac_EYmtch norm_vote_top2_share_sd EY_switch_dummy (total_1k_muni_aid_per_resident = reps_per_million ) if (year >= 2020 & year <= 2022), vce(cluster state) first
estat firststage

mat fstat = r(singleresults)
estadd scalar fs = fstat[1,4]

**** Export Table to Latex
cd "$Results"
esttab using "camp_finance_pac_2sls_20240709.tex", replace /// Replace file if it already exists
 collabels("\multicolumn{1}{c}{1l}" "\multicolumn{1}{c}{l2}") ///
 b(3) se(3) nomtitle label star(* 0.10 ** 0.05 *** 0.01) ///
 stats(N r2 fs, fmt(0 3) layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}")  labels(`"Observations"' `"\(R^{2}\)"' `"\(F\)"')) drop(_cons) ///
 booktabs ///
 title("Campaign Finance (PAC) 2sls") ///
 addnotes("Note: TKTKTKTK")
 

*2) panel sample  ----------------------------------------------------------------

eststo clear

//////////////////////// outcome 1 = % Change Incumbent Party Tot. Receipts
*** no controls, no fes
eststo: reg chng_log_inc_rcpts_EYmatch chng_log_prv_inc_rcpts_EYmtch c.reps_per_million##i.duringpandemic if year > 2012 , vce(cluster state)

estadd local office_fe "No"
estadd local year_fe "No"
estadd local state_fe "No"
estadd local norm_vote_year_fe "No"
estadd local office_state_fe "No"

*** no controls, no fes
eststo: reg chng_log_inc_rcpts_EYmatch chng_log_prv_inc_rcpts_EYmtch norm_vote_top2_share_sd  c.reps_per_million##i.duringpandemic norm_vote_top2_share_sd if year > 2012 , vce(cluster state)

estadd local office_fe "No"
estadd local year_fe "No"
estadd local state_fe "No"
estadd local norm_vote_year_fe "No"
estadd local office_state_fe "No"

*** Panel regressions estimating the differential relationship between reps per million and the incumbent
*** Col4: vote share during the pandemic by including state and year fixed effects
eststo: reghdfe chng_log_inc_rcpts_EYmatch chng_log_prv_inc_rcpts_EYmtch norm_vote_top2_share_sd c.reps_per_million##i.duringpandemic c.norm_vote_top2_share_sd#i.year if year > 2012 , vce(cluster state) a(sfips year)

estadd local office_fe "No"
estadd local year_fe "Yes"
estadd local state_fe "Yes"
estadd local norm_vote_year_fe "Yes"
estadd local office_state_fe "No"

** Col6: Adds Office by State Fixed Effects
eststo: reghdfe chng_log_inc_rcpts_EYmatch chng_log_prv_inc_rcpts_EYmtch norm_vote_top2_share_sd  c.reps_per_million##i.duringpandemic c.norm_vote_top2_share_sd#i.year if year > 2012 , vce(cluster state) a(sfips#office_num year)

estadd local office_fe "Yes"
estadd local year_fe "Yes"
estadd local state_fe "Yes"
estadd local norm_vote_year_fe "Yes"
estadd local office_state_fe "Yes"

//////////////////////// outcome 3 = Change (Log) Top Non-Inc. Receipts
*** Col1
eststo: reg chng_log_top_ninc_rcpts_EYmtch chng_log_prv_tninc_rcpts_EYmtch c.reps_per_million##i.duringpandemic if year > 2012 , vce(cluster state)

estadd local office_fe "No"
estadd local year_fe "No"
estadd local state_fe "No"
estadd local norm_vote_year_fe "No"
estadd local office_state_fe "No"

*** Col2
eststo: reg chng_log_top_ninc_rcpts_EYmtch chng_log_prv_tninc_rcpts_EYmtch norm_vote_top2_share_sd c.reps_per_million##i.duringpandemic norm_vote_top2_share_sd if year > 2012 , vce(cluster state)

estadd local office_fe "No"
estadd local year_fe "No"
estadd local state_fe "No"
estadd local norm_vote_year_fe "No"
estadd local office_state_fe "No"

*** Panel regressions estimating the differential relationship between reps per million and the incumbent
*** Col4: vote share during the pandemic by including state and year fixed effects
eststo: reghdfe chng_log_top_ninc_rcpts_EYmtch chng_log_prv_tninc_rcpts_EYmtch norm_vote_top2_share_sd  c.reps_per_million##i.duringpandemic c.norm_vote_top2_share_sd#i.year if year > 2012 , vce(cluster state) a(sfips year)

estadd local office_fe "No"
estadd local year_fe "Yes"
estadd local state_fe "Yes"
estadd local norm_vote_year_fe "Yes"
estadd local office_state_fe "No"

** Col6: Adds Office by State Fixed Effects
eststo: reghdfe chng_log_top_ninc_rcpts_EYmtch chng_log_prv_tninc_rcpts_EYmtch norm_vote_top2_share_sd  c.reps_per_million##i.duringpandemic c.norm_vote_top2_share_sd#i.year if year > 2012 , vce(cluster state) a(sfips#office_num year)

estadd local office_fe "Yes"
estadd local year_fe "Yes"
estadd local state_fe "Yes"
estadd local norm_vote_year_fe "Yes"
estadd local office_state_fe "Yes"

****** Export Table to Latex
cd "$Results/"
esttab using "camp_finance_panel_202407094.tex", replace ///
 collabels("\multicolumn{1}{c}{col1}" "\multicolumn{1}{c}{col2}" "\multicolumn{1}{c}{col3}" "\multicolumn{1}{c}{col4}" "\multicolumn{1}{c}{col5}" "\multicolumn{1}{c}{col6}" "\multicolumn{1}{c}{col7}" "\multicolumn{1}{c}{col8}") ///
 b(3) se(3) nomtitle label star(* 0.10 ** 0.05 *** 0.01) ///
 stats(N r2 office_fe year_fe state_fe norm_vote_year_fe office_state_fe, fmt(0 3) layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}")  labels(`"Observations"' `"\(R^{2}\)"' `"Office FE"' `"Year FE"' `"State FE"' `"Normal Vote x Year FE"' `"Office x State FE"')) drop(_cons) ///
 booktabs /// 
 title("Campaign Finance panel") ///
 addnotes("Note: TKTKTKTK")
 
 
 


 